export default {
    mounted(el, binding) {
        console.log("mounted");
        function debounce(fn, delay = 16) {
            let t = null;
            return function () {
                if (t) {
                    clearTimeout(t);
                }
                const context = this;
                const args = arguments;
                t = setTimeout(function () {
                    fn.apply(context, args);
                }, delay);
            };
        }

        el._resizer = new window.ResizeObserver(debounce(binding.value, Number(binding.arg) || 16));
        el._resizer.observe(el);
    },
    unmounted(el) {
        console.log("unmounted");
        el._resizer.disconnect();
    },
};
